﻿#ifndef CLIENT_H
#define CLIENT_H

#include <QWidget>
#include<QTcpSocket>
#include<QString>
#include<QtNetwork>
#include <QByteArray>
#include <string>
#include "src/Messenger.h"
#include "common/ControlCommands.h"

namespace Ui {
class Client;
}

class Client : public QWidget
{
    Q_OBJECT

public:
    explicit Client(QWidget *parent = 0);
    ~Client();

private slots:
    void on_Button_Connect_clicked();
    void on_Button_Break_clicked();

    void onTcpConnected();

    void onTcpBreak();

    void on_Button_ARM_Red_clicked();

    void on_Button_ARM_Green_clicked();

    void on_Button_ARM_Blue_clicked();

    void on_Button_FPGA_RED_clicked();

    void on_Button_FPGA_GREEN_clicked();

    void on_Button_FPGA_BLUE_clicked();

    void on_Button_TAIDA_GO_pressed();

    void on_Button_TAIDA_BACK_pressed();

    void on_speedBox_currentTextChanged(const QString &arg1);

    void on_pattern_currentTextChanged(const QString &arg1);

    void on_Button_TAIDA_GO_released();

    void on_Button_TAIDA_BACK_released();

    void on_linkmoveOut_clicked();

    void on_linkmoveIn_clicked();

    void on_pushButton_clicked();

private:
    Ui::Client *ui;
    Messenger *messenger;

    int BinToInt(const QString&);
    QString IntToBin(int);

    int DistanceToPlusCount(int x);

    void setButtonEnable(QObject*,bool);

    //三大封装函数

    void SendPlusCount(std::vector<QString>direction);//给电机方向{1,0,1},正反正

    void SendFreqCount(std::vector<int>);//给电机参数{2,5,9}, 2、5、9次计数产生一次脉冲

    void SendMove();
};

#endif // CLIENT_H
